﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;

namespace DataAccessLayer
{
    class ConnectionDTO
    {
        private string _StrConnection;
        private SqlConnection _Connection;

        public SqlConnection Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }

        public string StrConnection
        {
            get { return _StrConnection; }
            //set { _StrConnection = value; }
        }

        public ConnectionDTO()
        {
            // default connection
            _StrConnection = ConfigurationManager.ConnectionStrings["defaultStrConnection"].ConnectionString;
            _Connection = this.Start();
        }

        public SqlConnection Start()
        {
            SqlConnection connection = new SqlConnection(_StrConnection);
            connection.Open();
            return connection;
        }

        public void Stop()
        {
            _Connection.Close();
        }
    }
}
